package com.yc.service.impl;


import com.yc.mapper.ClassInfoMapper;
import com.yc.mapper.QuerymonitorMapper;
import com.yc.mapper.UserInfoMapper;
import com.yc.mapper.UserMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * 个人设置个人信息实现类（学生表 老师表 班级表）
 * @author zxy
 * @date : 2023-6-28
 */
@Api("个人设置个人信息实现类")
@Service
public class UserInfoServiceImpl {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private QuerymonitorMapper querymonitorMapper;
    @Resource
    private UserMapper userMapper;


    /**
     * 查询当前tid的班长和学委的信息
     * @author zxy
     * @param tid
     * @return 班长和学委的详细信息
     */
    @ApiOperation("查询当前老师'我的班级'的班长与学委信息")
    public List<Map<String, Object>> SelectBorXinfo(String tid){
        List<Map<String,Object>> teachclass = querymonitorMapper.Selectteachclass(tid);
        List<Map<String,Object>> Allinfo = new ArrayList<>();
        for (Map<String, Object> map : teachclass) {
            Map<String,Object> infomap = new HashMap<>();
            String cname = (String) map.get("cname");
            infomap.put("cname",cname);
            // 查询班长详细信息
            Map<String,Object> bmap =  querymonitorMapper.SelectBorXinfo(cname,1);
            infomap.put("b",bmap);
            // 查询学委详细信息
            Map<String,Object> Xmap =  querymonitorMapper.SelectBorXinfo(cname,2);
            infomap.put("x",Xmap);
            // 将信息存入集合
            Allinfo.add(infomap);
        }
        return Allinfo;
    }


    /**
     * 查询学生信息
     * @author zxy
     * @param stuid
     * @return 学生信息（班级 性别 辅导员 电话
     */
    @ApiOperation("查询学生的个人信息")
    public Map<String, Object> SelectStuInfo(String stuid){
        Map<String, Object> stuinfo = userInfoMapper.SelectStuInfo(stuid);
        return stuinfo;
    }

    /**
     * 查询老师信息
     * @author zxy
     * @param tid
     * @return 老师性别 老师电话
     */
    @ApiOperation("查询老师的个人信息")
    public Map<String, Object> SelectTeaInfo(String tid){
        Map<String, Object> Tinfo = userInfoMapper.SelectTeaInfo(tid);
        return Tinfo;
    }

    /**
     * 查出学年XXX班级老师的总课程
     * @param school_year
     * @param cname
     * @return
     */
    public List<Map<String, Object>> queryUserClassTotalByschoolYear(String school_year,String cname){
        List<Map<String, Object>> maps = userMapper.queryUserClassTotalByschoolYear(school_year, cname);
        return maps;
    }

    /**
     * 查出学年XXX班级老师的总课程
     * @param school_year
     * @param cname
     * @return
     */
    public List<Map<String, Object>> queryUserClassTotalByschoolYearUp(String school_year,String cname){
        List<Map<String, Object>> maps = userMapper.queryUserClassTotalByschoolYearUp(school_year, cname);
        return maps;
    }

    /**
     * 查出学年XXX班级老师的总课程
     * @param school_year
     * @param cname
     * @return
     */
    public List<Map<String, Object>> queryUserClassTotalByschoolYearDown(String school_year,String cname){
        List<Map<String, Object>> maps = userMapper.queryUserClassTotalByschoolYearDown(school_year, cname);
        return maps;
    }


}
